$(function() {
	$("#loginForm").submit(function() {
		X(this.action).post({
			body: $(this).serialize(),
			contentType: "application/x-www-form-urlencoded; charset=utf-8",
			success: function(req) {
				if (window["Titanium"]) {
					alert("Titanium!!");
					Titanium.fireEvent("loginSuccess", {
						
					});
				}
				alert("success!");
			},
			error: function(req) {
				var resp = JSON.parse(req.responseText);
				var errors = $(".errors");
				X(resp.errors).each(function(error) {
					$("<li/>", {
						text: error
					}).appendTo(errors);
				});
			}
		});
		return false;
	});
});
